<!-- 公司列表 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <p class="title-label mb10">公司列表</p>
    <dxtable
      :dataJson="dataJson"
      :portUrl="portUrl"
      :formJson="formJson"
      :qx="qx"
      ref="databale"
    ></dxtable>
  </div>
</template>
<script lang="ts" setup>
import dxtable from "../../components/util/dxtable.vue";
import sort from "../../components/util/sort.vue";
import { dxget, dxpost } from "../../util/index";
import { NButton, NImage, NTag } from "naive-ui";
import { h, ref, reactive } from "vue";
const databale = ref();
const xmlxSelect = ref([])
const initeer = () => {
  databale.value.initDataExpose();
};
let dataJson = [
  {
    title: "公司名称",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 24,
    key: "name",
    width: "",
    search: true,
    istable: true,
    required: false,
  },
  {
    title: "logo",
    type: "img",
    val: "",
    icon: "dx-img",
    span: 24,
    key: "logo",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "公司规模",
    type: "select",
    key: "gsgm",
    search: true,
    icon: "dx-biaodanzujian-xialakuang",
    render: (row) => {
        try{
            return  xmlxSelect.value.filter(a=>a.value==row.gsgm)[0].label 
        } catch(e){

        }
    }
  },
  {
    title: "公司性质",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "gsxz",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "行业",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "hangye",
    width: "",
    search: false,
    istable: true,
    required: false,
  },

  {
    title: "排序",
    width: 100,
    render: (row) => {
      row.sjk = "chuanbo"; //数据库
      row.databaseName = "gongsi"; //表名
      return h(sort, {
        row,
        onCallBack: () => {
          initeer();
        },
      });
    },
  },
  {
    title: "添加时间",
    key: "addTime",
    width: 150,
  },
];

const qx = {
  DeletePermissionID: "cbrcgongsidel", //删除
  EditPermissionIdentifier: "cbrcgongsibj", // 编辑
  NewPermissionIdentifier: "cbrcgongsixz", // 新建
  ViewPermissionID: "cbrcgongsick", // 查看
};
const portUrl = "cbrc/gongsi/gongsi";

let formJson = reactive([
  {
    title: "公司名称",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 24,
    key: "name",
    width: "",
    search: false,
    istable: true,
    required: true,
  },
  {
    title: "logo",
    type: "img",
    val: "",
    icon: "dx-img",
    span: 12,
    key: "logo",
    width: "",
    search: false,
    istable: true,
    required: false,
  },{
    title: "公司规模",
    type: "select",
    icon: "dx-biaodanzujian-xialakuang",
    options: [],
    val: "",
    span: 12,
    key: "gsgm",
    width: 0,
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "公司性质",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "gsxz",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "行业",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "hangye",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "简介",
    type: "textarea",
    val: "",
    icon: "dx-duohangwenben",
    span: 24,
    key: "jianjie",
    width: "",
    search: false,
    istable: true,
    required: true,
  }
  
]);
const czFun = {
  fun: (row) => {
    return [
      h(
        NButton,
        {
          type: "info",
          quaternary: true,
          onClick: async (e) => {},
        },
        "复制代码"
      ),
    ];
  },
};

// 获取字典内容
const xtgxxmfl = async () => {
  const { data }: any = await dxget("dxgjAdmin/getzd", { name: 'cbrcgsgm' })
  dataJson[2].options = [
    {
      label: "全部",
      value: ""
    },
    ...data
  ]
  formJson[2].options = data
  xmlxSelect.value = data
  console.log(data);
}
xtgxxmfl()
</script>
<style scoped></style>
